package com.gzhryc.shared_device.bxscn.code.dao.db;

import com.gzhryc.common.StringTools;
import com.gzhryc.jdbc.annotaion.*;
import com.gzhryc.shared_device.bxscn.code.dao.enums.PortableEnergyBatteryEnum;

import java.io.Serializable;
import java.util.Date;

/**
 * 便携式储能电池
 * @version 2023-08-28
 */
@Table(name = "dev_portable_energy_battery")
public class PortableEnergyBattery implements Serializable {

    private static final long serialVersionUID = 1L;

	@Id(auto = false)
    @Column(name = "device_sn", length = 32, notNull = true, note = "设备序列号")
    protected String deviceSn;

    @Column(length = 32, notNull = true,note = "设备类型")
    protected String type;

    @Column(name="type_name",length = 32, notNull = true,note = "设备类型名称")
    protected String typeName;

    @Column(name="battery_power",notNull = true, note = "电池功率")
    protected Integer batteryPower;

    @Column(name = "version_number", note = "版本号")
    protected String versionNumber;

    @Column(name = "lease_type", notNull = true, defVal = "1",note = "租借方式")
    protected Integer leaseType;

    @Column(name="user_id",note = "用户ID")
    protected Long userId;

    @Column(name = "belong_date",note = "归属时间")
    protected Date belongDate;

    //设备

    @Column(name = "cabinet_device_sn", length = 32, note = "充电柜设备序列号")
    protected String cabinetDeviceSn;

    @Column(name = "slot_num", note = "当前卡槽位置")
    protected Integer slotNum;

    @Column(name = "power", note = "电量")
    protected Double power;

    //网点

    @Index(name="place_id")
    @Column(name = "place_id",note = "网点ID")
    protected Long placeId;

    @Column(name = "place_name",length = 32,note = "网点名称")
    protected String placeName;

    @Column(note = "省")
    protected String province;

    @Column(note = "城市")
    protected String city;

    @Column(name = "city_area",note = "城区")
    protected String cityArea;

    @Column(name = "area_code", length = 128, note = "地区ID，以逗号分隔")
    protected String areaCode;

    @Column(name = "bind_note",note = "绑定信息")
    protected String bindNote;

    @Column(name = "deploy_date",note = "部署时间")
    protected Date deployDate;

    //运行

    @Column(name = "current_trade_no", length = 32, note = "当前执行的订单")
    protected String currentTradeNo;

    @Column( notNull = true, defVal = "1", note = "设备状态")
    protected Integer state;

    @Column(name = "last_lease_date", note = "最后租借时间")
    protected Date lastLeaseDate;

    @Column(name = "last_heart_date", note = "最后心跳时间")
    protected Date lastHeartDate;

    @Column(name = "update_date", note = "修改时间", autoUpdateTime = true)
    protected Date updateDate;

    @Column(name = "create_date",notNull = true)
    protected Date createDate;

    @JoinField(name = "name",fromField = "user_id",toTable = "user_info",type = "LEFT")
    protected String userName;

    @JoinField(name = "phone",fromField = "user_id",toTable = "user_info",type = "LEFT")
    protected String userPhone;

    public String getDeviceSn() {
        return deviceSn;
    }

    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public Integer getBatteryPower() {
        return batteryPower;
    }

    public void setBatteryPower(Integer batteryPower) {
        this.batteryPower = batteryPower;
    }

    public Integer getLeaseType() {
        return leaseType;
    }

    public void setLeaseType(Integer leaseType) {
        this.leaseType = leaseType;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Date getBelongDate() {
        return belongDate;
    }

    public void setBelongDate(Date belongDate) {
        this.belongDate = belongDate;
    }

    public String getCabinetDeviceSn() {
        return cabinetDeviceSn;
    }

    public void setCabinetDeviceSn(String cabinetDeviceSn) {
        this.cabinetDeviceSn = cabinetDeviceSn;
    }

    public Integer getSlotNum() {
        return slotNum;
    }

    public void setSlotNum(Integer slotNum) {
        this.slotNum = slotNum;
    }

    public String getVersionNumber() {
        return versionNumber;
    }

    public void setVersionNumber(String versionNumber) {
        this.versionNumber = versionNumber;
    }

    public Double getPower() {
        return power;
    }

    public void setPower(Double power) {
        this.power = power;
    }

    public Long getPlaceId() {
        return placeId;
    }

    public void setPlaceId(Long placeId) {
        this.placeId = placeId;
    }

    public String getPlaceName() {
        return placeName;
    }

    public void setPlaceName(String placeName) {
        this.placeName = placeName;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCityArea() {
        return cityArea;
    }

    public void setCityArea(String cityArea) {
        this.cityArea = cityArea;
    }

    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    public String getBindNote() {
        return bindNote;
    }

    public void setBindNote(String bindNote) {
        this.bindNote = bindNote;
    }

    public Date getDeployDate() {
        return deployDate;
    }

    public void setDeployDate(Date deployDate) {
        this.deployDate = deployDate;
    }

    public String getCurrentTradeNo() {
        return currentTradeNo;
    }

    public void setCurrentTradeNo(String currentTradeNo) {
        this.currentTradeNo = currentTradeNo;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getLastLeaseDate() {
        return lastLeaseDate;
    }

    public void setLastLeaseDate(Date lastLeaseDate) {
        this.lastLeaseDate = lastLeaseDate;
    }

    public Date getLastHeartDate() {
        return lastHeartDate;
    }

    public void setLastHeartDate(Date lastHeartDate) {
        this.lastHeartDate = lastHeartDate;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPhone() {
        return userPhone;
    }

    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }

    public String getStateName(){
        return PortableEnergyBatteryEnum.State.note(this.state);
    }

    public String getLeaseTypeName(){
        return PortableEnergyBatteryEnum.LeaseType.note(this.leaseType);
    }

    public String getAreaName(){
        String result = "";
        if(StringTools.isNotBlank(this.province)) {
            result = this.province;
        }
        if(StringTools.isNotBlank(this.city)) {
            result = result + this.city;
        }
        if(StringTools.isNotBlank(this.cityArea)) {
            result = result + this.cityArea;
        }
        return result;
    }
}
